﻿using System;
using System.Windows.Media.Imaging;
using MSAP.Framework.Interfaces;
using MSAP.Framework;

using Data;

namespace PLL.Notes
{
    public class NotesModule : ModuleBase
    {
        public NotesModule()
            : base("NOTES", "Notes", "Notes", new BitmapImage(new Uri("/PLL.Notes;component/Resources/Notes.png", UriKind.Relative)))
        {
            // Nothing todo     
        }

        public override void Init(IShell shell)
        {
            base.Init(shell);
            ServiceActions.Add(new CreateNotesServicePage_SA(this));
            
            // Creation d'entrée pipo, pour faire la doc
            ServiceActions.Add(new ServiceActionCommand("NOTES.NOTES_SA1", "NOTES.NOTES_SA1", "Contacts", "", null,null,true,null,this));
            ServiceActions.Add(new ServiceActionCommand("NOTES.NOTES_SA2", "NOTES.NOTES_SA2", "Taches", "", null, null, true, null, this));
            ServiceActions.Add(new ServiceActionCommand("NOTES.NOTES_SA3", "NOTES.NOTES_SA3", "Note de frais", "", null, null, true, null, this));


            // create samples data
            TableNotes.Load();
            if (TableNotes.Records.Count == 0)
            {
                // Pas de données, sauvegardé, faire un jeu d'essai
                for (int i = 0; i < 30; i++)
                {
                    Note note = TableNotes.CreateRecord();
                    note.Date = DateTime.Now.AddDays((double)i);
                    note.Titre = "Titre N°" + i.ToString();
                    note.Description = "Description N°" + i.ToString();
                }
            }
        }

        public NoteSet TableNotes
        {
            get
            {
                if (m_TableNotes == null)
                    m_TableNotes = new NoteSet();
                return m_TableNotes;
            }
        }

        private NoteSet m_TableNotes;
    }
}
